// 测试地址
// const baseUrl = "http://47.99.242.58/unionpay/"
const baseUrl = "http://ety54x.natappfree.cc/unionpay/"
// 正式地址
// const baseUrl = "https://v1.ruida-pay.api.vastchain.ltd/unionpay/"
const request = (url, options) => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: baseUrl + url,
            method: options.method,
            data: options.method === 'GET' ? options.data : JSON.stringify(options.data),
            header: {
                'Content-Type': 'application/json; charset=UTF-8'
            },
            success(res) {
                resolve(res)
            },
            fail(err) {
                reject(err)
            }
        })
    })
}

const get = (url, options) => {
    return request(url, { method: 'GET', data: options })
}
const post = (url, options) => {
    return request(url, { method: 'POST', data: options })
}
module.exports = {
    baseUrl: baseUrl,
    get: get,
    post: post
}